
//test for council room card

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <stdlib.h>
#include <time.h>
#include <math.h>

#define NUMBER_TESTS 10000
#define NOISY_TEST 1

int pass = 0;
int fail = 0;

int printPass(){
  printf("council_room card: PASS\n");
  //pass++
  return 0;
}

int printFail(){
  printf("council_room card: FAIL\n");

  return 0;
}





int CRtest() {

  int r;
  int seed = 1000;
  int numPlayer = 2;
  int pos = 1;
  int k[10] = {adventurer, council_room, feast, gardens, mine,
               remodel, smithy, village, baron, great_hall};
  int bonus = 0;
  struct gameState G;
  int s;
  //int pass = 0;
  //int fail = 0;
  
  

  r = initializeGame(numPlayer, k, seed, &G);

 
  puts("\n\n********* TESTING COUNCIL ROOM ************\n");
  

  printf ("initializeGame(%d, k, 1, &G) = %d\n", numPlayer, r);
  assert(r == 0);
  
  int count1 = numHandCards(&G);                    //randomize number of cards in hand
  count1 = rand() % 10;
  int count2 = numHandCards(&G);
  int buys1 = G.numBuys;                            //randomize number of buys
  buys1 = rand() % 5;
  int buys2 = G.numBuys;
  
  
#if (NOISY_TEST == 1)
  printf("player: %d\n", whoseTurn(&G) );
  printf("count before: %d\n", count1 );
  printf("buys before: %d\n", buys1 );
#endif

  s = cardEffect(council_room,0,0,0,&G,pos,&bonus);
  assert(s == 0);
  
#if (NOISY_TEST == 1)
  printf("count after: %d\n", numHandCards(&G) );
  printf("buys after: %d\n", G.numBuys );
#endif

  if(numHandCards(&G) == count1 + 3 && G.numBuys == buys1 + 1){
    printPass();
    pass++;
  } else {
    printFail();
    fail++;
  }

  //printf("Number of Passing tests: %d\n", pass);
  //printf("Number of Failing tests: %d\n", fail);


  

  return 0;
}

int main(){

  srand(time(NULL));

  for(int i = 0; i < NUMBER_TESTS; i++){
      CRtest();
  }

  printf("Number of Passing tests: %d\n", pass);
  printf("Number of Failing tests: %d\n", fail);


  return 0;
}